package com.alibaba.csp.sentinel.cluster.log;

import java.io.File;

import com.alibaba.csp.sentinel.eagleeye.EagleEye;
import com.alibaba.csp.sentinel.eagleeye.StatLogger;
import com.alibaba.csp.sentinel.log.LogBase;

public final class ClusterStatLogUtil {

    private static final String FILE_NAME = "sentinel-cluster.log";

    private static final StatLogger statLogger;

    static {
        String path = LogBase.getLogBaseDir() + FILE_NAME;

        statLogger = EagleEye.statLoggerBuilder("sentinel-cluster-record")
                .intervalSeconds(1)
                .entryDelimiter('|')
                .keyDelimiter(',')
                .valueDelimiter(',')
                .maxEntryCount(5000)
                .configLogFilePath(path)
                .maxFileSizeMB(300)
                .maxBackupIndex(3)
                .buildSingleton();
    }

    public static void log(String msg) {
        statLogger.stat(msg).count();
    }

    public static void log(String msg, int count) {
        statLogger.stat(msg).count(count);
    }

    private ClusterStatLogUtil() {
    }
}
